﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Metriks
{
    /// <summary>
    /// Preuzeto i prilagođeno sa http://blogs.microsoft.co.il/blogs/tamir/archive/2006/12/14/RichTextBox-syntax-highlighting.aspx
    /// </summary>
    public class SyntaxProvider
    {
        static List<string> tags = new List<string>();
        static List<char> specials = new List<char>();

        static SyntaxProvider()
        {
            string[] strs = {
                "void",
                "int",
                "double",
                "function",
                "endfunction",
                "returns",
                "return",
                "if",
                "elsif",
                "else",
                "endif",
                "while",
                "endwhile",
                "do",
                "then"
            };
            tags = new List<string>(strs);

            char[] chrs = {
                '.',
                ')',
                '(',
                '[',
                ']',
                '>',
                '<',
                ':',
                ';',
                '\n',
                '\t'
            };
            specials = new List<char>(chrs);
        }


        public static List<char> GetSpecials
        {
            get { return specials; }
        }
        public static List<string> GetTags
        {
            get { return tags; }
        }
        public static bool IsKnownTag(string tag)
        {
            //return tags.Exists(delegate(string s) { return s.ToLower().Equals(tag.ToLower()); });
            return tags.Contains(tag);
        }
        public static List<string> GetProvider(string tag)
        {
            return tags.FindAll(delegate(string s) { return s.ToLower().StartsWith(tag.ToLower()); });
        }
    }
}
